home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / Spiral wipe.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  114 lines

  1. /**********************************************************************\
  2.  
  3. File:        Spiral wipe.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 1
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short SpiralGyra(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Start in the topleft corner, facing downwards.  Copy until you hit (a) the
  34.    edge of the screen, or (b) bits you've already copied.  Then turn counter-
  35.    clockwise and do it again.  */
  36.    
  37. pascal short SpiralGyra(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  38. {
  39.     int                stop,sbottom,sleft,sright,iterrow,itercol,direction;
  40.     Rect            source;
  41.     Boolean            everyOther;
  42.     int                BOXSIZE;
  43.     RgnHandle        boundsRgn;
  44.     
  45.     boundsRgn=NewRgn();
  46.     RectRgn(boundsRgn, &boundsRect);
  47.     BOXSIZE=theWindowHeight/15;
  48.     everyOther=FALSE;
  49.     stop=0;
  50.     sbottom=theWindowHeight/BOXSIZE-(theWindowHeight%BOXSIZE ? 0 : 1);
  51.     sleft=0;
  52.     sright=theWindowWidth/BOXSIZE-(theWindowWidth%BOXSIZE ? 0 : 1);
  53.     direction=3;
  54.     iterrow=stop;
  55.     itercol=sleft;
  56.     while ((stop<=sbottom)&&(sleft<=sright))
  57.     {
  58.         StartTiming();
  59.         source.top=iterrow*BOXSIZE;
  60.         source.bottom=source.top+BOXSIZE;
  61.         source.left=itercol*BOXSIZE;
  62.         source.right=source.left+BOXSIZE;
  63.         OffsetRect(&source, boundsRect.left, boundsRect.top);
  64.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  65.             &source, &source, 0, boundsRgn);
  66.         switch (direction)
  67.         {
  68.             case 0:  /* facing right */
  69.                 if (itercol==sright)
  70.                 {
  71.                     sbottom--;
  72.                     direction++;
  73.                     iterrow--;
  74.                 }
  75.                 else itercol++;
  76.                 break;
  77.             case 1:  /* facing up */
  78.                 if (iterrow==stop)   /* that reads "s top," not "stop" */
  79.                 {
  80.                     sright--;
  81.                     direction++;
  82.                     itercol--;
  83.                 }
  84.                 else iterrow--;
  85.                 break;
  86.             case 2:  /* facing left */
  87.                 if (itercol==sleft)
  88.                 {
  89.                     stop++;
  90.                     direction++;
  91.                     iterrow++;
  92.                 }
  93.                 else itercol--;
  94.                 break;
  95.             case 3:  /* facing down */
  96.                 if (iterrow==sbottom)
  97.                 {
  98.                     sleft++;
  99.                     direction=0;
  100.                     itercol++;
  101.                 }
  102.                 else iterrow++;
  103.                 break;
  104.         }
  105.         if (everyOther)
  106.             TimeCorrection(CorrectTime);
  107.         everyOther=!everyOther;
  108.     }
  109.     
  110.     DisposeRgn(boundsRgn);
  111.     
  112.     return 0;
  113. }
  114.